<?php
namespace app\Controllers;
use app\Models\AuthorizationModel as Authorization;

class AuthorizationController {

	//抽取UserModel对象父类
	protected $model;

	public function __construct() {
		$this -> model = new Authorization();
	}

	//查询用户控制器
	public function searchAuthorization() {
		$result = $this -> model -> searchAuthorizationModel();
		echo json_encode($result);
	}

	//删除用户控制器
	public function deleteAuthorization($request, $response) {
		$id = $request -> getParam("id");
		$result = $this -> model -> deleteAuthorizationModel($id);
		echo json_encode($result);
	}

	//修改用户控制器
	public function modifyAuthorization($request, $response) {
		$userid = $request -> getParam("userid");
		$username = $request -> getParam("username");
		$fullname = $request -> getParam("fullname");
		$authorization = Array();
		$authorization["relationid"] = $relationid;
		$authorization["username"] = $username;
		$authorization["fullname"] = $fullname;
		$authorization["role"] = $role;
		$result = $this -> model -> modifyAuthorizationModel($authorization);
		echo json_encode($result);
	}

	//增加用户控制器
	public function insertAuthorization($request, $response) {
		$username = $request -> getParam("username");
		$fullname = $request -> getParam("fullname");
		$authorization = Array();
		$authorization["username"] = $username;
		$authorization["fullname"] = $fullname;
		$authorization["role"] = $role;
		$result = $this -> model -> insertAuthorizationModel($authorization);
		echo json_encode($result);
	}

}
?>